/**
 * Copyright (c) Software Institude of PKU
 * All rights reserved. 
 * This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 */
package edu.pku.sei.modeler.model.uml.Kernel;
// imports:
import java.util.Iterator;

import org.w3c.dom.Element;

import edu.pku.sei.modeler.model.common.MetaTypedList;
import edu.pku.sei.modeler.model.xml.XMLUtility;
import edu.pku.sei.modeler.uml.modelHelper.ModelPackage;
import edu.pku.sei.modeler.uml.util.MetaTypedSet;



/**
 * @generated
 * modified by zsj
 */
public class TypedElement extends NamedElement implements ITypedElement {
	// attributes
	
	
	
	
	// references
	
	protected MetaTypedList type;
	
	
	
	// getters & setters for attributes
	
	// getters for references
	
	public MetaTypedList getType() {
		if(type == null) {
			type = new MetaTypedSet(Type.class, this, ModelPackage.TYPEDELEMENT_TYPE);
		}
		return type;
	}
	
	// save & load
	public void serialize(Element root) {
		super.serialize(root);
		// attributes
		
		// references
		
		XMLUtility.xmlInstance.serializeNodesNotContain(root, ModelPackage.TYPEDELEMENT_TYPE, type);		
		
	}
	
	public void deSerialize(Element root) {
		super.deSerialize(root);
		// attributes
		
		// references
		
		this.getType().addAll(XMLUtility.xmlInstance.deSerializeNodesNotContain(root, ModelPackage.TYPEDELEMENT_TYPE, this));
		
	}
	
	public void dynamicSet(String featureID, Object value) {
		if(featureID == null || "".equals(featureID)) {
			return;
		}
		// attributes
		
		// references
		
		else if(ModelPackage.TYPEDELEMENT_TYPE.equals(featureID)) {
			getType().add(value);
		}
		
		else
			super.dynamicSet(featureID, value);
	}
	
	//add by zsj
	public String toString() {
		StringBuffer types = new StringBuffer();
		for (Iterator iter = type.iterator(); iter.hasNext();) {
			Type element = (Type) iter.next();
			types.append(element + ",");
		}
		
		if (types.length() > 0) {
			return types.substring(0, types.length() -1);
		}
		else {
			return types.toString();
		}
	}
	//end of adding
}
 
 
 
 
 